package com.lyf.scm.job.remote.facade;


import cn.hutool.core.date.DateUtil;
import com.lyf.scm.common.enums.ResponseMsg;
import com.lyf.scm.job.remote.BigDataSalesPlanRemoteService;
import com.rome.arch.core.clientobject.Response;
import com.rome.arch.core.exception.RomeException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;

/**
 * description:
 *
 * @author: haodong
 * @data: 2020/11/2 14:52
 */
@Slf4j
@Component
public class BigDataSalesPlanFacade {
    @Resource
    private BigDataSalesPlanRemoteService bigDataSalesPlanRemoteService;
    /**
     * 处理job
     *
     * @param
     * @return void
     **/
    public void handleApiDispatcher() {
        Date now = new Date();
        String specifiedDate = DateUtil.formatDate(DateUtil.beginOfWeek(now));
        Response response = bigDataSalesPlanRemoteService.handleApiDispatcher(specifiedDate);
        if (!ResponseMsg.SUCCESS.getCode().equals(response.getCode())) {
            log.error("================== 执行大数据Job 失败 ==================");
            throw new RomeException(response.getCode(), response.getMsg());
        }
        log.info("================== 执行大数据Job 成功 ==================");
    }
}
